package cn.rkylin.oms.sysreturn.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.sysreturn.dao.ISysReturnDAO;
import cn.rkylin.oms.sysreturn.domain.SysReturn;
import cn.rkylin.oms.sysreturn.vo.SysReturnVO;

/**
 * 类名:SysReturnDAOImpl <br/>
 * 作用: 退货单数据访问类. <br/>
 * 创建原因:	 退货单数据库访问操作. <br/>
 * 创建时间:     2017年9月28日 下午8:18:58 <br/>
 * @author   zhanghao
 * @version  v1.0 
 */
@Repository("sysReturnDAO")
public class SysReturnDAOImpl implements ISysReturnDAO {
    @Autowired
    IDataBaseFactory dao;
    
    private String STATEMENT_INSERT_SELECTIVE = "insertSelectiveSysReturn";
    private String STATEMENT_UPDATE_SELECTIVE = "updateSelectiveSysReturn";

    private String STATEMENT_UPDATE_UN_APPR_SYS_RETURN = "updateUnApprExtSysReturn";
    
    private String STATEMENT_SELECT_SELECTIVE = "selectSelectiveSysReturn";
    private String STATEMENT_SELECT_SELECTIVE_EXTEND = "selectSelectiveSysReturnExtend";
    private String STATEMENT_SELECT_BY_REFUND = "selectSysReturnBySysRefundId";

    private String STATEMENT_UPDATE_CANCEL_EXT = "updateCancelExtSysReturn";
    private String STATEMENT_UPDATE_CANCEL_LOCAL = "updateCancelLocalSysReturn";
    /**
     * TODO [简要描述复写方法的内容].
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#deleteByPrimaryKey(java.lang.String)
     */
    @Override
    public int deleteByPrimaryKey(String returnId) {
        
        // TODO Auto-generated method stub
        return 0;
    }

    /**
     * TODO [简要描述复写方法的内容].
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#insert(cn.rkylin.oms.sysreturn.domain.SysReturn)
     */
    @Override
    public int insert(SysReturn record) {
        
        // TODO Auto-generated method stub
        return 0;
    }

    /**
     * 退货单新增操作.
     * @throws Exception 
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#insertSelective(cn.rkylin.oms.sysreturn.domain.SysReturn)
     */
    @Override
    public int insertSelective(SysReturn record) throws Exception {
        return dao.insert(STATEMENT_INSERT_SELECTIVE, record);
    }

    /**
     * TODO [简要描述复写方法的内容].
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#selectByPrimaryKey(java.lang.String)
     */
    @Override
    public SysReturn selectByPrimaryKey(String returnId) {
        
        // TODO Auto-generated method stub
        return null;
    }

    /**
     * TODO [简要描述复写方法的内容].
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#updateByPrimaryKeySelective(cn.rkylin.oms.sysreturn.domain.SysReturn)
     */
    @Override
    public int updateByPrimaryKeySelective(SysReturn record) {
        // TODO Auto-generated method stub
        return 0;
    }

    /**
     * TODO [简要描述复写方法的内容].
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#updateByPrimaryKey(cn.rkylin.oms.sysreturn.domain.SysReturn)
     */
    @Override
    public int updateByPrimaryKey(SysReturn record) {
        
        // TODO Auto-generated method stub
        return 0;
    }

    /**
     * 退货单更新操作.
     * @throws Exception 
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#updateBySelective(cn.rkylin.oms.sysreturn.vo.SysReturnVO)
     */
    @Override
    public int updateBySelective(SysReturnVO record) throws Exception {
        return dao.update(STATEMENT_UPDATE_SELECTIVE, record);
    }

    /**
     * TODO [简要描述复写方法的内容].
     * @throws Exception 
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#selectBySelectiveValue(cn.rkylin.oms.sysreturn.vo.SysReturnVO)
     */
    @Override
    public List<SysReturn> selectBySelectiveValue(SysReturnVO sysReturnVO) throws Exception {
        return dao.findAllList(STATEMENT_SELECT_SELECTIVE, sysReturnVO);
        
    }

    /**
     * @throws Exception 
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#cancelSysReturn4Ext(cn.rkylin.oms.sysreturn.vo.SysReturnVO)
     */
    @Override
    public int cancelSysReturn4Ext(SysReturnVO param) throws Exception {
        return dao.update(STATEMENT_UPDATE_CANCEL_EXT, param);
    }

    /**
     * @throws Exception 
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#cancelSysReturn4Local(cn.rkylin.oms.sysreturn.vo.SysReturnVO)
     */
    @Override
    public int cancelSysReturn4Local(SysReturnVO param) throws Exception {
        return dao.update(STATEMENT_UPDATE_CANCEL_LOCAL, param);
    }

    /**
     * @throws Exception 
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#updateUnApproveSysReturn(cn.rkylin.oms.sysreturn.vo.SysReturnVO)
     */
    @Override
    public int updateUnApproveSysReturn(SysReturnVO param) throws Exception {
        return dao.update(STATEMENT_UPDATE_UN_APPR_SYS_RETURN, param);
    }

    /**
     * @throws Exception 
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#selectBySelectiveValueExtend(cn.rkylin.oms.sysreturn.vo.SysReturnVO)
     */
    @Override
    public List<SysReturnVO> selectBySelectiveValueExtend(SysReturnVO queryParam) throws Exception {
        return dao.findAllList(STATEMENT_SELECT_SELECTIVE_EXTEND, queryParam);
    }

    /**
     * @throws Exception
     * @see cn.rkylin.oms.sysreturn.dao.ISysReturnDAO#selectBySelectiveValueExtend(cn.rkylin.oms.sysreturn.vo.SysReturnVO)
     */
    @Override
    public List<SysReturnVO> selectByRefundId(String refundId) throws Exception {
        return dao.findAllList(STATEMENT_SELECT_BY_REFUND, refundId);
    }

    /**
     * 通过来源ID获取系统退货单
     * @param sourceId
     * @return
     * @throws Exception
     */
    @Override
    public List<SysReturn> selectSysReturnForSysOrder(String sourceId) throws Exception {
        return dao.findList("selectSysReturnForSysOrder", sourceId);
    }
}

